Skip to content

Fix repeat of negative prompt#4335

Merged
patrickvonplaten merged 2 commits intohuggingface:mainfrom
ml-research:sega_fix_negativ_prompt
Jul 28, 2023
Merged

Fix repeat of negative prompt#4335
patrickvonplaten merged 2 commits intohuggingface:mainfrom
ml-research:sega_fix_negativ_prompt

Conversation

@kathath
Copy link
Copy Markdown
Contributor

@kathath kathath commented Jul 28, 2023

Fixes #4149 (running a batch of prompts and negative prompts with the SemanticStableDiffusionPipeline causes an error).

The same bug was fixed for the StableDiffusion pipeline in #1120 .

Who can review?

@patrickvonplaten

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

HuggingFaceDocBuilderDev commented Jul 28, 2023

The documentation is not available anymore as the PR was closed or merged.

@patrickvonplaten
Copy link
Copy Markdown
Contributor

Hey @kathath,

Can you explain how this PR fixes the negative prompt? To me both implementations you are showing are identical

@kathath
Copy link
Copy Markdown
Contributor Author

kathath commented Jul 28, 2023

@patrickvonplaten What changed is that when negative_prompt is not None, there is no repeat by batch_size anymore.

When negative prompts are given, the code expects the negative prompt list to be the same length as the prompt list. This is checked in line elif batch_size != len(negative_prompt):
Therefore, when negative_prompt is not None, there is no need to repeat by batch_size. The previous implementation unnecessarily repeated by batch_size. That was leading to a dimension mismatch error.

@patrickvonplaten
Copy link
Copy Markdown
Contributor

Thanks for the explanation!

@patrickvonplaten patrickvonplaten merged commit faa6cbc into huggingface:main Jul 28, 2023
@patrickvonplaten patrickvonplaten deleted the sega_fix_negativ_prompt branch July 28, 2023 16:14
orpatashnik pushed a commit to orpatashnik/diffusers that referenced this pull request Aug 1, 2023
orpatashnik pushed a commit to orpatashnik/diffusers that referenced this pull request Aug 1, 2023
orpatashnik pushed a commit to orpatashnik/diffusers that referenced this pull request Aug 1, 2023
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running a batch of prompts and negative prompts in SemanticStableDiffusionPipeline causes tensor dimension mismatch

3 participants